home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Gooey1.3.1 / C++ Templates / Window.c < prev   
Text File  |  1994-04-14  |  8KB  |  299 lines

  1. $$Loop Windows
  2. $$Message User Window, u:$Worksheet.name$.cp
  3.  
  4. $$File u:$Worksheet.name$.cp
  5. /*  $Worksheet.name$                                 Handle this Window */
  6. /*  $CopyRight$ */
  7.  
  8. /* 
  9.     File name: $Worksheet.name$
  10.     Function: Handle a Window 
  11.     History: $Date$ Original by $Author$
  12.  
  13. */
  14.  
  15. #include "mmCommon$Prototype.name$.h"    /* Common */
  16. #include "Common$Prototype.name$.h"        /* Common */
  17.  
  18. /* ======================================================= */
  19. /* ======================================================= */
  20.  
  21. void CW$Worksheet.name$::Init()
  22. {
  23. inherited::Init();
  24. }
  25.  
  26.  
  27. $$if Option.EXTRAHOOKS
  28. /* ======================================================= */
  29.  
  30. void CW$Worksheet.name$::CloseExtras(Ptr theWS)
  31. {
  32. $Worksheet.name$PRec        myWS;
  33.  
  34. inherited::CloseExtras(theWS);
  35. myWS = ($Worksheet.name$PRec)theWS;
  36. }
  37.  
  38. /* ======================================================= */
  39.  
  40. void CW$Worksheet.name$::UpdateExtras(Ptr theWS)
  41. {
  42. $Worksheet.name$PRec        myWS;
  43.  
  44. inherited::UpdateExtras(theWS);
  45. myWS = ($Worksheet.name$PRec)theWS;
  46. }
  47.  
  48. /* ======================================================= */
  49.  
  50. void CW$Worksheet.name$::OpenExtras(Ptr theWS)
  51. {
  52. $Worksheet.name$PRec        myWS;
  53.  
  54. inherited::OpenExtras(theWS);
  55. myWS = ($Worksheet.name$PRec)theWS;
  56. }
  57.  
  58. /* ======================================================= */
  59.  
  60. void CW$Worksheet.name$::ActivateExtras(Boolean Do_An_Activate,Ptr theWS)
  61. {
  62. $Worksheet.name$PRec        myWS;
  63.  
  64. inherited::ActivateExtras(Do_An_Activate,theWS);
  65. myWS = ($Worksheet.name$PRec)theWS;
  66.  
  67. if (!Do_An_Activate)                            /* Handle the deactivate */
  68.     {
  69.     }
  70. else
  71.     {
  72.     }
  73. }
  74.  
  75. /* ======================================================= */
  76.  
  77. void CW$Worksheet.name$::HandleExtraButtons(Ptr theWS,ControlHandle theControl,short *UnHiliteValue)
  78. {
  79. $Worksheet.name$PRec        myWS;
  80. short                theSelection;
  81. long                RefCon;
  82.  
  83.  
  84. inherited::HandleExtraButtons(theWS,theControl,UnHiliteValue);
  85. myWS = ($Worksheet.name$PRec)theWS;
  86.  
  87. RefCon = GetCRefCon(theControl);                    /* get control refcon */
  88.  
  89. switch (RefCon)                                        /* Select correct button */
  90.     {
  91.     $$Loop Control.type = Button
  92.     case ResC_$Control.name$:                    /* Button, $Control.FullName$ */
  93.         break;
  94.     $$EndLoop Control.type = Button
  95.     $$Loop Control.type = HotRect
  96.     $$if Control.HotSpot
  97.     case ResC_$Control.name$:                    /* HotSpot, $Control.FullName$ */
  98.         break;
  99.     $$endif Control.HotSpot
  100.     $$EndLoop Control.type = HotRect
  101.     $$Loop Control.type = Icon
  102.     $$if Control.NonGraphic
  103.     case ResC_$Control.name$:                    /* Icon, $Control.FullName$ */
  104.         break;
  105.     $$endif Control.NonGraphic
  106.     $$EndLoop Control.type = Icon
  107.     $$Loop Control.type = Sicn
  108.     $$if Control.NonGraphic
  109.     case ResC_$Control.name$:                    /* Sicn, $Control.FullName$ */
  110.         break;
  111.     $$endif Control.NonGraphic
  112.     $$EndLoop Control.type = Sicn
  113.     $$Loop Control.type = Picture
  114.     $$if Control.NonGraphic
  115.     case ResC_$Control.name$:                    /* Picture, $Control.FullName$ */
  116.         break;
  117.     $$endif Control.NonGraphic
  118.     $$EndLoop Control.type = Picture
  119.     $$Loop Control.type = UButton
  120.     case ResC_$Control.name$:                    /* Plugin Button, $Control.FullName$ */
  121.         break;
  122.     $$EndLoop Control.type = UButton
  123.     $$Loop Control.type = Popup
  124.     case ResC_$Control.name$:                    /* PopUp, $Control.FullName$ */
  125.         theSelection = GetCtlValue(myWS->Ctrl_$Control.name$);    /* Get the Popup selection value */
  126.         switch (theSelection)                    /* Select correct item */
  127.             {
  128.             $$Loop PopupItems
  129.             case $Control.PopupID$:                /* $Control.PopupID$, for $Control.PopupName$ */
  130.                 break;
  131.             $$EndLoop PopupItems
  132.  
  133.             default:                            /* allow other buttons, trap for debug */
  134.                 break;                            /* end of otherwise */
  135.             }                                    /* end of switch */
  136.         break;
  137.     $$EndLoop Control.type = Popup
  138.     $$Loop Control.type = Palette
  139.     case ResC_$Control.name$:                /* Tool palette, $Control.FullName$ */
  140.         break;
  141.     $$EndLoop Control.type = Palette
  142.  
  143.     default:                                    /* allow other buttons, trap for debug */
  144.         break;                                /* end of otherwise */
  145.     }                                            /* end of switch */
  146. }
  147.  
  148. $$if Worksheet.CheckboxesOrRadios
  149. /* ======================================================= */
  150.  
  151. void CW$Worksheet.name$::HandleExtraCheckboxes(Ptr theWS,ControlHandle theControl)
  152. {
  153. $Worksheet.name$PRec        myWS;
  154. long    RefCon;                                        /* RefCon for controls */
  155.  
  156.  
  157. inherited::HandleExtraCheckboxes(theWS,theControl);
  158. myWS = ($Worksheet.name$PRec)theWS;
  159.  
  160. RefCon = GetCRefCon(theControl);                    /* get control refcon */
  161.  
  162. switch (RefCon)                                        /* Select correct control */
  163.     {
  164.     $$Loop Control.type = Checkbox
  165.     case ResC_$Control.name$:                        /* Checkbox, $Control.FullName$  */
  166.         if (myWS->Value_$Control.name$ == 0)
  167.             {
  168.             }
  169.         else
  170.             {
  171.             }
  172.         break;
  173.         
  174.     $$EndLoop Control.type = Checkbox
  175.     $$Loop Control.type = UToggle
  176.     case ResC_$Control.name$:                        /* Plugin Toggle, $Control.FullName$  */
  177.         if (myWS->Value_$Control.name$ == 0)
  178.             {
  179.             }
  180.         else
  181.             {
  182.             }
  183.         break;
  184.         
  185.     $$EndLoop Control.type = UToggle
  186.     $$Loop Control.type = Radio
  187.     case ResC_$Control.name$:                        /* Radio, $Control.FullName$  */
  188.         break;
  189.     $$EndLoop Control.type = Radio
  190.  
  191.     default:                                    /* allow other checkboxes and radios, trap for debug */
  192.         break;                                    /* end of otherwise */
  193.     }                                            /* end of case */
  194. }
  195.  
  196. $$endif
  197. $$if Worksheet.Scrollbars
  198. /* ======================================================= */
  199.  
  200. /* Routine: HandleScrollBar */
  201. /* Purpose: Handle a ScrollBar being pressed */
  202.  
  203. void CW$Worksheet.name$::HandleScrollBar(short code,ControlHandle theControl,Point myPt)
  204. {
  205. long    RefCon;                                    /* RefCon for controls */
  206.  
  207.  
  208. inherited::HandleScrollBar(code,theControl,myPt);
  209. RefCon = GetCRefCon(theControl);                /* get control refcon */
  210.  
  211. switch (RefCon)                                    /* Select correct scrollbar */
  212.     {
  213.     $$Loop Control.type = ScrollBar
  214.     case ResC_$Control.name$:                    /* Scroll bar, $Control.FullName$  */
  215.         break;
  216.  
  217.     $$EndLoop
  218.     $$Loop Control.type = UGauge
  219.     case ResC_$Control.name$:                    /* Plugin gauge, $Control.FullName$  */
  220.         break;
  221.  
  222.     $$EndLoop
  223. $$if Worksheet.Document
  224. $$if Worksheet.ScrollHorz
  225.     case 12345L:                                /* Window, scroll horz */
  226.         break;
  227.  
  228. $$endif
  229. $$if Worksheet.ScrollVert
  230.     case 12346L:                                /* Window, scroll vert */
  231.         break;
  232.  
  233. $$endif
  234. $$endif Worksheet.Document
  235.     default:                                    /* allow other buttons, trap for debug */
  236.         break;                                    /* end of otherwise */
  237.     }                                            /* end of switch */
  238. }
  239.  
  240. $$endif
  241. /* ======================================================= */
  242.  
  243. /* Routine: HandleEvent */
  244. /* Purpose: Handle action to our window, like controls */
  245.  
  246. void CW$Worksheet.name$::HandleEvent(EventRecord *myEvent)
  247. {
  248. short            code;                            /* Location of event in window or controls */
  249. WindowPtr        whichWindow;                    /* Window pointer where event happened */
  250. Point            myPt;                            /* Point where event happened */
  251. ControlHandle    theControl;                        /* Handle for a control */
  252. $Worksheet.name$PRec        theWS;
  253.  
  254.  
  255. inherited::HandleEvent(myEvent);
  256. code = FindWindow(myEvent->where,&whichWindow);    /* Get where in window and which window */
  257.  
  258. if (this->RecPtr != nil)                        /* Only do if the window is us */
  259.     {
  260.     theWS = this->RecPtr;
  261.  
  262.     $$if HasEditLists
  263.     if (myEvent->what == mouseDown)
  264.         {
  265.         myPt = myEvent->where;                    /* Get mouse position */
  266.         GlobalToLocal(&myPt);                    /* Make it relative */
  267.  
  268.         $$Loop Control.type = EditText
  269.         if (PtInRect(myPt,&theWS->TERect_$Control.name$))    /* Check for pressed in the TE  Edit Text  */
  270.             {
  271.             }
  272.  
  273.         $$EndLoop Control.type = EditText
  274.         $$Loop Control.type = List
  275.         if (PtInRect(myPt,&theWS->ListRect_$Control.name$))    /* Check for pressed in list */
  276.             {
  277.             }
  278.  
  279.         $$EndLoop Control.type = List
  280.         }
  281.  
  282.     $$endif HasEditLists
  283.     if ((theWS->theWindow == whichWindow) && (code == inContent))    /* for our window */
  284.         {
  285.         myPt = myEvent->where;                    /* Get mouse position */
  286.         GlobalToLocal(&myPt);                    /* Make it relative */
  287.  
  288.         code = FindControl(myPt,whichWindow,&theControl);    /* Get type of control */
  289.         }
  290.     }
  291. }
  292.  
  293. $$endif Option.EXTRAHOOKS
  294.  
  295. /* ======================================================= */
  296. /* ======================================================= */
  297. $$CloseFile
  298. $$EndLoop
  299.